package com.jdrx.sw.sewage.api.web;

import com.jdrx.platform.commons.rest.beans.dto.IdDTO;
import com.jdrx.platform.commons.rest.beans.vo.ResponseVO;
import com.jdrx.platform.commons.rest.factory.ResponseFactory2;
import com.jdrx.sw.sewage.beans.dto.base.PageDTO;
import com.jdrx.sw.sewage.beans.entity.AiReportPO;
import com.jdrx.sw.sewage.beans.vo.AiForecastVO;
import com.jdrx.sw.sewage.beans.vo.AiWindReportVO;
import com.jdrx.sw.sewage.beans.vo.base.PageVO;
import com.jdrx.sw.sewage.common.constant.Constant;
import com.jdrx.sw.sewage.service.AiForecastServiceImpl;
import com.jdrx.sw.sewage.service.AiModelParamServiceImpl;
import com.jdrx.sw.sewage.service.AiReportServiceImpl;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.validation.Valid;
import java.util.List;
import java.util.Map;

/**
 * 智能碳源加药demo
 *
 * @author Administrator
 */
@RestController
@RequestMapping(value = "/api/carbonSource")
@Api(value = "智能碳源")
public class CarbonSourceApi {

    @Autowired
    private AiModelParamServiceImpl aiModelParamServiceImpl;
    @Autowired
    private AiForecastServiceImpl aiForecastServiceImpl;
    @Autowired
    private AiReportServiceImpl aiReportServiceImpl;

    @ApiOperation(value = "查询统计信息")
    @RequestMapping(value = "findStatistics", method = RequestMethod.POST)
    public ResponseVO<Map<String, Object>> findStatistics(@RequestHeader(Constant.DATA_NODE) String dataNode,
                                                          @RequestHeader(Constant.TENANT_ID) String tenantId) {
        return ResponseFactory2.ok(aiModelParamServiceImpl.findStatistics("智能碳源"));
    }

    @ApiOperation(value = "查询智能碳源分析结果")
    @RequestMapping(value = "findCarbonSourceForecast", method = RequestMethod.POST)
    public ResponseVO<Map<String, List<AiForecastVO>>> findCarbonSourceForecast(@RequestHeader(Constant.DATA_NODE) String dataNode,
                                                                                @RequestHeader(Constant.TENANT_ID) String tenantId) {
        return ResponseFactory2.ok(aiForecastServiceImpl.findCarbonSourceForecast("智能碳源"));
    }

    @ApiOperation(value = "查询智能碳源ai对话框")
    @RequestMapping(value = "findCarbonSourceAiWind", method = RequestMethod.POST)
    public ResponseVO<List<AiWindReportVO>> findCarbonSourceAiWind(@RequestHeader(Constant.DATA_NODE) String dataNode,
                                                                   @RequestHeader(Constant.TENANT_ID) String tenantId) {
        return ResponseFactory2.ok(aiReportServiceImpl.findCarbonSourceAiWind("智能碳源"));
    }

    @ApiOperation(value = "查询智能碳源周报列表")
    @RequestMapping(value = "selectWeekReportByPage", method = RequestMethod.POST)
    public ResponseVO<PageVO<AiReportPO>> selectWeekReportByPage(@RequestHeader(Constant.DATA_NODE) String dataNode,
                                                                 @RequestHeader(Constant.TENANT_ID) String tenantId,
                                                                 @RequestBody @Valid PageDTO dto) {
        return ResponseFactory2.ok(aiReportServiceImpl.selectWeekReportByPage(dto, "智能碳源", 4));
    }

    @ApiOperation(value = "查询智能碳源周报详情")
    @RequestMapping(value = "selectWeekReportById", method = RequestMethod.POST)
    public ResponseVO<AiReportPO> selectWeekReportById(@RequestHeader(Constant.DATA_NODE) String dataNode,
                                                       @RequestHeader(Constant.TENANT_ID) String tenantId,
                                                       @RequestBody @Valid IdDTO dto) {
        return ResponseFactory2.ok(aiReportServiceImpl.selectWeekReportById(dto));
    }
}